<?php if (!defined('GRS')) exit;

$game_id = $grs->params("game_id");
$mode_id = $grs->params("mode_id");

?>

<link type='text/css' href="css/style.css" rel='stylesheet' media='screen' />
<script type="text/javascript" src="js/script.js"></script>


<div id='grs'>
	<noscript><?php echo $grs->message("JavaScriptDisable")?></noscript>
<!-- ------------------------  Admin Mini Panel --------------------------------------------------- -->
	<?php if(iADMIN): ?>
		<?php include "admin_panel.php"?>   	   
	<?php endif ?>
    
<!-- ------------------------  Intro --------------------------------------------------- -->
	
<!--	<div class="grs-intro">
		<p>
			Bienvenido a Game Rec System, preciona el boton y disfruta
		</p>
		<button onclick="showGames();">Click Me</button>
	</div>-->
	
<!-- ------------------------  Game Table List --------------------------------------------------- -->
<?php if(!$game_id && !$mode_id): ?>
    <div id="games" style="display:none" >
       <?php opentable(htmlspecialchars($grs->message("ChooseGameLabel"))); ?>  
       <div class="list_game"></div>
       <?php closetable(); ?> 
    </div>
    
<!-- ------------------------  Mode Table List --------------------------------------------------- -->
    <div id="modes" style="display:none">
        <?php opentable(htmlspecialchars($grs->message("ChooseModeLabel"))); ?>
        <div class="list_mode"></div>
        <?php closetable(); ?> 
    </div>

<?php elseif($game_id && $mode_id): ?>	
<!-- ------------------------  Show Result --------------------------------------------------- -->
	<div id="recs">
		<?php $recs = $grs->getRec($game_id, $mode_id); ?>
		<?php opentable(sprintf($grs->message('ResultTableLabel'), $grs->getGameById($game_id), $mode_id == 'all' ? 'all' : $grs->getModeById($mode_id))); ?>
		<?php if($recs):?> 
			 <table class="horizontal-table">
				<tr>
				   <th>Player</th>
				   <th>Car</th>
				   <th>Track</th>
				   <th>Time</th>
				</tr>
			<?php foreach($recs as $rec):?>                      
				<tr>
				   <td><?php echo htmlspecialchars($rec->player)?></td> <!-- nombre del jugador -->
				   <td><?php echo htmlspecialchars($rec->car) ?></td> <!-- coche -->
				   <td><?php echo htmlspecialchars($rec->track) ?></td> <!-- pista -->
				   <td><?php echo $rec->time ?></td> <!-- tiempo o record -->
				</tr>
			<?php endforeach ?>
			</table>
		<?php endif ?>
		<?php closetable(); ?> 
	</div>
	<?php endif ?>

</div> <!--end grs div-->
